﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Palsta.Core.data;

namespace Palsta.Core.function
{
    class XsltFunctionManager
    {

        private static Hashtable functions = null;

        private static void Init()
        {
            functions = new Hashtable();

            functions.Add("string", new Xslt_string());


            functions.Add("true", new Xslt_true());
            functions.Add("false", new Xslt_false());
        }

        public static Field ExecuteFunction(String name, Field[] args)
        {
            if (functions == null)
            {
                Init();
            }

            XsltFunction f = (XsltFunction)functions[name];
            if (f == null)
            {
                return null;
            }

            return f.Execute(args);
        }

        public static FieldType GetReturnType(String name)
        {
            if (functions == null)
            {
                Init();
            }

            XsltFunction f = (XsltFunction)functions[name];
            if (f == null)
            {
                return FieldType.String;
            }

            return f.GetReturnType();
        }

    }
}
